function BaseInfo() {
    var baseUrl = "/m/jsondata";

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getBaseInfo = function getBaseInfo(taskId, callback) {
        var ret1 = null;
        jQuery.ajax({
            url: "/m/baseInfo/getBaseInfo".addTimestamp(),
            data: {"taskId": taskId},
            dataType: "json",
            type: "GET",
            success: function (res) {
                if (res.data != null && res.data.length > 1) {
                    ret1 = res.data;
                }
            },
            complete:function () {
                if(callback){
                    callback(ret1);
                }
            }
        })
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getAllGrade = function (taskId, callback) {
        jQuery.ajax({
            url: baseUrl + "/grades?taskId=" + taskId,
            success: function (ret) {
                if (ret != "") {
                    var list = JSON.parse(ret);
                    callback(list);
                }
            }
        });
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getAllClass = function (taskId, callback) {
        jQuery.ajax({
            url: baseUrl + "/classes?taskId=" + taskId,
            success: function (ret) {
                if (ret != "") {
                    var list = JSON.parse(ret);
                    callback(list);
                }
            }
        });
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getAllCourse = function (taskId, callback) {
        jQuery.ajax({
            url: baseUrl + "/courses?taskId=" + taskId,
            success: function (ret) {
                if (ret != "") {
                    var list = JSON.parse(ret);
                    callback(list);
                }
            }
        });
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getAllTeacher = function (taskId, callback) {
        jQuery.ajax({
            url: baseUrl + "/teachers?taskId=" + taskId,
            success: function (ret) {
                if (ret != "") {
                    var list = JSON.parse(ret);
                    callback(list);
                }
            }
        });
    }

    /**
     * 获取课程列表
     * @param taskId
     * @param gradeId
     * @param callback
     */
    this.getCourseListByGradeId = function (taskId, gradeId, callback) {
        var data = {
            "taskId": taskId,
        }

        if (gradeId > 0) {
            data = {
                "taskId": taskId,
                "gradeId": gradeId
            }
        }

        $.ajax({
            url: baseUrl + "/courses",
            data: data,
            success: function (ret) {
                if (ret != "") {
                    var courseList = JSON.parse(ret);
                    callback(courseList);
                }
            }
        });
    }

    /**
     *
     * @param taskId
     * @param gradeId
     * @param courseId
     * @param callback
     */
    this.getCourseTeacherListBy = function (taskId, gradeId, courseId, callback) {
        var data = {
            "taskId": taskId
        }

        if (gradeId > 0) {
            data.gradeId = gradeId;
        }

        if (courseId > 0) {
            data.courseId = courseId;
        }

        $.ajax({
            url: baseUrl + "/course_teacher",
            data: data,
            success: function (ret) {
                if (ret != "") {
                    var list = JSON.parse(ret);
                    callback(list);
                }
            }
        });
    }

    /**
     *
     * @param taskId
     * @param callback
     */
    this.getGradesAndClassesList = function (taskId, callback) {
        jQuery.ajax({
            url: baseUrl + "/getGradesAndClasses?taskId=" + taskId,
            success: function (ret) {
                if (ret != "") {
                    var obj = JSON.parse(ret);
                    list = obj.data;

                    var arr = [];
                    for (var i = 0; i < list.length; i++) {
                        var grade = JSON.parse(list[i].grade);
                        var classes = JSON.parse(list[i].classes);
                        var item={};
                        item.grade = grade;
                        item.classes = classes;
                        arr.push(item);
                    }
                    callback(arr);
                }
            }
        });
    }


    /**
     * 获取课时结构
     * @param taskId
     * @param callback
     */
    this.getTimetableStructure = function (taskId, callback) {
        $.ajax({
            url: baseUrl + "/timetable_structure?taskId=" + taskId,
            success: function (ret) {
                if (ret != "") {
                    var obj = JSON.parse(ret);
                    obj.getLessonsPerDay = function () {
                        return this.amLessonCount + this.pmLessonCount + this.eveLessonCount;
                    };
                    callback(obj);
                }
            }
        });
    }
}